package com.qianyu.project.mapper.provider.base;

import org.apache.ibatis.jdbc.SQL;

/**
 * @author gs
 * @date create in 2020/12/24 8:14
 */
public class SystemAuthorityMapperProvider {

    public String selectByRole(String role) {
        return new SQL(){
            {
                SELECT("distinct a.*");
                FROM("system_role r,system_authority a,system_role_authority ra");
                WHERE("ra.role_id=r.id");
                WHERE("ra.authority_id=a.id");
                WHERE("a.authority_status='Y'");
                WHERE("r.id in (${value})");
            }
        }.toString();
    }

    public String selectRootByRole(){
        return new SQL(){
            {
                SELECT("distinct a.*");
                FROM("system_role r,system_authority a,system_role_authority ra");
                WHERE("ra.role_id=r.id");
                WHERE("ra.authority_id=a.id");
                WHERE("a.authority_status='Y'");
                WHERE("a.authority_pid is null");
                WHERE("r.id in (${value})");
            }
        }.toString();
    }
}
